package 集合.LIST;
import java.util.ArrayList;

public class ArrayListDemo4 {
    public static void main(String[] args) {
        ArrayList<ArrayListDemo4Student>list=new ArrayList<>();//添加一个类
        ArrayListDemo4Student s1=new ArrayListDemo4Student();
        ArrayListDemo4Student s2=new ArrayListDemo4Student();
        ArrayListDemo4Student s3=new ArrayListDemo4Student();
        list.add(s1);
        list.add(s2);
        list.add(s3);
        System.out.print("[");
        for (int i = 0; i < list.size(); i++) {
            ArrayListDemo4Student stu=list.get(i);
         System.out.print(stu.getAge()+","+stu.getName()+",");

        }
        System.out.println("]");
    }
}
